package com.core.util;

import org.apache.log4j.Logger;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
/**
 * 设置spring 上下文
 * @author laker
 *
 */
public final class DspContext {
	static Logger logger = Logger.getLogger(DspUtil.Log4J);
	private static ApplicationContext ctx ;

	/**
	 * @return the ctx
	 */
	public static ApplicationContext getCtx() {
		return ctx;
	}

	/**
	 * @param ctx the ctx to set
	 */
	public static void setCtx(ApplicationContext ac) {
		ctx = ac;
	}
	
	public static Object getBean(String beanName){
		Object obj = null;
		try {
			obj = ctx.getBean(beanName);
		} catch(BeansException be) {
			logger.error(be.getMessage());
		}
		return obj;
	}
}
